#include<iostream>
#include<string>

using std::cout;
using std::endl;
using std::string;

template<typename T,int Knum=10>
class Stack
{
public:

    Stack()
    :_num(-1)
     ,_capacity(new T[Knum]())
    {}

    ~Stack()
    {
        if(_capacity)
        {
            delete []_capacity;
            _capacity=nullptr;
        }
    }

    void push(const T& a)
    {
        _capacity[++_num]=a;
    }

    void pop();

    T top()
    {
        if(_num>=0)
        return _capacity[_num];
        else 
        {
            cout<<"wrong"<<endl;
            return 0 ;
        }
    }

private:
        int _num;
    T * _capacity;

};
template<typename T,int Knum>
void Stack<T, Knum>::pop()
{
    --_num;
}
int main(void)
{
    Stack<int,20> testi;
    for(int i=0;i<10;i++)
    {
        testi.push(i);
    }

    for(int i=0;i<10;i++)
    {
        cout<<testi.top()<<endl;
        testi.pop();
    }
    cout<<endl;
    Stack<double> testb;
    testb.push(3.14);
    cout<<testb.top()<<endl;;
}


